package edu.info.manager.service;

import edu.info.manager.dao.TeacherDao;

import edu.info.manager.domain.TeacherJavaBean;

public class TeacherService {
    public TeacherJavaBean Tea[] = TeacherDao.FindId();
    TeacherDao teacherDao = new TeacherDao();

    public static TeacherJavaBean[] FindAllTeacher() {
        TeacherJavaBean teacherJavaBean[]=TeacherDao.FindId();
        boolean flag=false;
        for (int i = 0; i < teacherJavaBean.length; i++) {
            TeacherJavaBean Tea=teacherJavaBean[i];
            flag=true;
            break;
        }
        if (flag)
        {
            return teacherJavaBean;
        }
        else
        {
            return null;
        }
    }


    public boolean isExists(String id) {

//        for (int i = 0; i < Tea.length; i++) {
//            System.out.println(Tea[i]);
//        }
        for (int i = 0; i < Tea.length; i++) {

            if (Tea[i] != null && Tea[i].getId().equals(id)) {

                return true;
            }
        }
        return false;
    }


    public boolean AddTeacher(TeacherJavaBean tea) {
        return teacherDao.Addteacher(tea);
    }

    public boolean UpdateTeachher(String updateid, TeacherJavaBean newstu) {
        return teacherDao.UpdateTeacher(updateid, newstu);
    }


    public boolean DeleteTeacher(String delnum) {
        return teacherDao.DeleteTeacher(delnum);
    }
}
